<template>
    <div>
        <el-header>满标复审</el-header>
        <el-row>
           <br>
        </el-row>
        <el-row>
            <el-col :span="20" :offset="2">
                <el-row style="background-color: #E4E7ED;height: 40px;">
                    <el-col :span="3" style="margin-top: 5px;">
                        <span>&nbsp</span>
                        <span>&nbsp</span>
                        <i class="el-icon-search"
                            style="font-size: 20px;"></i>
                        <span style="font-size: 20px;">高级查询</span>
                    </el-col>
                    <el-col :span="1" :offset="17" style="font-size: 20px;">
                        <el-button icon="el-icon-search" type="success" @click="searchFullProject">查询</el-button>
                    </el-col>
                    <el-col :span="1" :offset="1" style="font-size: 20px;">
                        <el-button icon="el-icon-refresh-right" type="success" @click="resetFullProject" plain>重置</el-button>
                    </el-col>
                </el-row>
                <el-row style="border: 1px solid gray;height: 80px;">
                    <el-col :span="4" :offset="1" style="margin-top: 20px;">
                        <el-input placeholder="用户名" v-model="search.uname" clearable></el-input>
                    </el-col>
                    <el-col :span="4" :offset="2" style="margin-top: 20px;">
                        <el-input placeholder="项目名称" v-model="search.pname" clearable></el-input>
                    </el-col>
                    <el-col :span="4" :offset="2" style="margin-top: 20px;">
                        <el-input placeholder="借款人名" v-model="search.name" clearable></el-input>
                    </el-col>
                    <el-col :span="4" :offset="2" style="margin-top: 20px;">
                        <el-input placeholder="借款金额" v-model="search.money" clearable></el-input>
                    </el-col>
                </el-row>
                <el-row style="background-color: #E4E7ED;height: 40px;margin-top: 40px;">
                    <el-col :span="3" style="margin-top: 8px;">
                        <i class="el-icon-document"
                            style="font-size: 20px;"></i>
                        <span>数据记录</span>
                    </el-col>
                    <el-col :span="1" :offset="18" style="font-size: 20px;">
                        <el-button icon="el-icon-document-copy" type="success">导出表格</el-button>
                    </el-col>
                </el-row>
                <el-row>
                    <el-table :data="projects" style="width: 100%" >
                        <el-table-column prop="pid" label="编号" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="uname" label="用户名" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="name" label="借款人姓名" align="center" width="100">
                        </el-table-column>
                        <el-table-column prop="pname" label="项目名称" align="center" width="100">
                        </el-table-column>
                        <el-table-column prop="type" label="项目类型" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="money" label="借款金额" align="center" width="120">
                        </el-table-column>
                        <el-table-column prop="rate" label="年化利率" align="center" width="80">
                            <template slot-scope="scope">
                                {{ formatToPercentage(scope.row.rate) }}
                            </template>
                        </el-table-column>
                        <el-table-column prop="deadline" label="借款期限" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="cmoney" label="募集金额" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="status" label="状态" align="center" width="80">
                        </el-table-column>
                        <el-table-column label="操作" width="160" align="center" fixed="right">
                            <template slot-scope="scope">
                                <el-button type="success" icon="el-icon-check" @click="handlePass(scope.row)"></el-button>
                                <el-button type="danger" icon="el-icon-close" @click="handleReviewFailed(scope.row)"></el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-row>
                <el-row>
                    <div style="text-align: center">
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                            :current-page="page" :page-sizes="[5, 10]" :page-size="size"
                            layout="total, sizes, prev, pager, next, jumper" :total="total">
                        </el-pagination>
                    </div>
                </el-row>

            </el-col>
        </el-row>
    </div>
</template>
<script>
export default{
    data(){
        return{
            search:{
                uname:"",
                pname:"",
                name:"",
                money:"",
                page: 1,
                size: 5,
            },
            projects:[],
            page: 1,
            size: 5,
            total: 0,
            totalPage: 0,
        }
    },methods:{
        searchFullProject(){
            this.$axios.post("/project/searchFullProject",this.search).then(res =>{
                if(res.data.code == 200){
                    this.projects = res.data.data.data;
                    this.total = res.data.data.total;
                    this.totalPage = res.data.data.totalPage;
                }
            })
        },
        resetFullProject(){
            this.search={
                uname:"",
                pname:"",
                name:"",
                money:"",
                page: 1,
                size: 5,
            }
        },
        handlePass(row){
            console.log(row);
        },
        handleReviewFailed(row){
            console.log(row);
            this.$axios.post("/project/ReviewFailed", row).then(res => {
                if(res.data.code==200){
                    this.$message({
                        message: '审核未通过!',
                        type: 'error'
                    });
                    this.searchFullProject();
                }
            })
        },
        handleSizeChange(val) {
            this.search.size = val;
            this.searchFullProject()
        },
        handleCurrentChange(val) {
            this.search.page = val;
            this.searchFullProject()
        },
        formatToPercentage(row){
            let rate = row * 100 + "%"
            return rate;
        },
    },mounted(){
        this.searchFullProject()
    }
}
</script>
<style scoped>
.el-header {
    background-color: #67C23A;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
</style>